<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">

<title>医疗机构列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jq.js"></script>
<script src="js/admin.js"></script>
</head>
<body>
	<form method="post" action="" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder">角色信息列表</strong>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li> <a class="button border-main icon-plus-square-o" 
					href="page/role/addRole.jsp"> 新建角色</a> </li>
					<li>搜索：</li>
					<li><input type="text" placeholder="请输入搜索关键字" name="keywords"
						class="input"
						style="width:250px; line-height:17px;display:inline-block" /> <a
						href="javascript:void(0)" class="button border-main icon-search"
						onclick="changesearch()"> 搜索</a></li>
				</ul>
			</div>
			<table class="table table-hover text-center">
			  <tr>
	    		<th>ID</th>
	    		<th>角色编号</th>
	    		<th>角色名称</th>
	    		<th>操作</th>
    		  </tr>
				
			<c:forEach items="${lr}" var="r" >
    		<tr>
    			<td>${r.id }</td>
    			<td>${r.roleId }</td>
    			<td>${r.roleName }</td>
    			<td><div class="button-group">
				<a class="button border-main" href="javaScript:void(0)"onclick="edit('${r.roleId }','${r.roleName }')">
				<span class="icon-edit"></span> 修改</a> 
				<a class="button border-red" href="javaScript:void(0)" onclick="del('${r.roleId}')">
				<span class="icon-trash-o"></span> 删除</a>
				</div></td>
    		</tr>
    		</c:forEach>
			</table>
			
		</div>
	</form>

</body>
<script type="text/javascript">
	function del(rid) {
		if (confirm("您确定要删除吗?")) {
			$.post("RoleServlet", {method:"RoleDelete",roleId:rid}, function(data) {
				if (eval(data)) {
					alert("角色删除成功！")
					window.location.href = "RoleServlet?method=findRole&&fr=role"
				} else {
					alert("修改失败")
				}
			})
		}
	}
	function edit(rid,rname){
		window.location.href = "page/role/updateRole.jsp?rid="+rid+"&&rname="+rname
	}
</script>
</html>
